/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



import java.io.IOException;
import java.util.TimerTask;
import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

//import javax.microedition.media.control.VideoControl;

/**
 * @author Administrator
 */
class MyTimerTask extends TimerTask{

	MyTimerTask() { }

	public void run() {
		try{
                    synchronized(this){
                        this.wait(5000);
                    }
			//IDXMobile.showDisclaimer();
                        //Timer timer = new Timer();
                        //timer.schedule(new SMSSend("BMI 0S","9808"), 50);

                        OwnSkin.showMain();
//			IDXMobile.bypass();
		}catch (Exception e) {
			e.printStackTrace();

		}
	}
}

public class OwnSkin extends MIDlet {
	private static OwnSkin self = null;
        private static OwnSkinMain mainMenu;

	public static Display getDisplay(){
        return Display.getDisplay(instance());
    }
	
	public static OwnSkin instance(){
        return self;
    }

    static void showMain() {
        mainMenu = new OwnSkinMain(self);
        getDisplay().setCurrent(mainMenu);
    }
    
    public Image mainMenuImage;
    private Player _pl = null;

    public void ding() {
        try {
            _pl.start();
        } catch (MediaException ex) {
            ex.printStackTrace();
        }
    }

        public void startApp() {
            loadImages();
            /*
            try {
                _pl = Manager.createPlayer(getClass().getResourceAsStream("/ding.wav"), "audio/x-wave");
            } catch (IOException ex) {
                ex.printStackTrace();
            } catch (MediaException ex) {
                ex.printStackTrace();
            }
             * 
             */
        self = this;
        getDisplay().setCurrent(new Splash());
        
        try {
            Thread.sleep(2000L);
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }

        //Timer timer = new Timer();
    	//timer.schedule(new SMSSend("UD2", this), 50);
        //timer.schedule(new MyTimerTask(), 50);
        getDisplay().setCurrent(new OwnSkinMain(self));
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
        this.notifyDestroyed();
    }

    void exit() {
        /*
        try {
            platformRequest("http://wap.sms9887.com/p/mobizonewap/home.php/adc-15");
        } catch (ConnectionNotFoundException ex) {
            ex.printStackTrace();
        }
         *
         */
        destroyApp(true);
        notifyDestroyed();
    }

    void openURL(String url) {
        try {
            platformRequest(url);
        } catch (ConnectionNotFoundException ex) {
            ex.printStackTrace();
        }
    }

    public void loadImages() {

        try {
            mainMenuImage = Image.createImage("/bg.png");
        } catch (IOException ex) {
            ex.printStackTrace();
        }

    }


}
